home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-27 | 2.1 KB | 68 lines | [TEXT/CWIE] |
- /* SK8 © 1997 Apple Computer, Inc.
- This code is protected under the current SK8 License
- See http://sk8.research.apple.com/ for more information
- Apple Research Laboratories
- */
-
- import java.awt.*;
-
- class label extends rectangle {
-
- // constructor.
-
- public label() {
- super();
- this.settext("Untitled");
- this.setfillcolor(sk8.white);
- this.setframesize(0);
- // this.setresizeable(false);
- this.bindlabeltext();
- }
-
- //======================================================================
- // changing the text requires changing the size of it.
- //======================================================================
-
- public void bindlabeltext () {
- Point textsize = this.actortextsize();
- int framesize = this.framesize();
- int width = textsize.x + framesize + 10;
- int height = textsize.y + framesize + 14;
- Rectangle mybounds = this.boundsrect(true);
- symbol textloc = this.textlocation();
- if ((textloc == sk8.quote("CENTER")) || (textloc == sk8.quote("TOPCENTER")) || (textloc == sk8.quote("BOTTOMCENTER"))) {
- this.setsize(width, height, false, false);
- } else if ((textloc == sk8.quote("TOPLEFT")) || (textloc == sk8.quote("CENTERLEFT")) || (textloc == sk8.quote("BOTTOMLEFT"))) {
- this.setboundsrect(mybounds.x, mybounds.y, width, height, true, false, false);
- } else if ((textloc == sk8.quote("TOPRIGHT")) || (textloc == sk8.quote("CENTERRIGHT")) || (textloc == sk8.quote("BOTTOMRIGHT"))) {
- int newleft = mybounds.x + mybounds.width - width;
- int newtop = mybounds.y + mybounds.height - height;
- this.setboundsrect(newleft, newtop, newleft + width, newtop + height);
- }
- }
-
- public void settext (String thetext) {
- super.settext(thetext);
- this.bindlabeltext();
- }
-
- public void settextfont (String name) {
- super.settextfont(name);
- this.bindlabeltext();
- }
-
- public void settextsize (int newsize) {
- super.settextsize(newsize);
- this.bindlabeltext();
- }
-
- public void settextstyle (int newstyle) {
- super.settextstyle(newstyle);
- this.bindlabeltext();
- }
-
- public void setframesize (int newsize) {
- super.setframesize(newsize);
- this.bindlabeltext();
- }
- }